//
//  ContentView.swift
//  maozzi-rss
//
//  Created by 帽子 on 2020/5/21.
//  Copyright © 2020 帽子. All rights reserved.
//

import SwiftUI

struct ContentView: View {
    @EnvironmentObject var userData: UserData

    @State var showingProfile = false

    // 用户头像，设置
    var profileButton: some View {
        Button(action: { self.showingProfile.toggle() }) {
            Image(systemName: "person.crop.circle")
                .imageScale(.large)
                .accessibility(label: Text("User Profile"))
                .padding()
        }
    }

    var body: some View {
        NavigationView {
            IndexListView()
                .environmentObject(self.userData)
                .navigationBarTitle(Text("帽子 RSS"), displayMode: .large)
                .navigationBarItems(trailing: self.profileButton)
                .sheet(isPresented: self.$showingProfile) {
                    SettingsView(isPresented: self.$showingProfile)
                        .environmentObject(self.userData)
                }
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
